package com.aranandroid.customview

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.aranandroid.customview.ui.*
import com.blankj.utilcode.util.SPUtils
import kotlinx.android.synthetic.main.item_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        SPUtils.getInstance().put("iii",1)
        setContentView(R.layout.activity_main)
        val listView = findViewById<RecyclerView>(R.id.listview)
        listView.layoutManager = LinearLayoutManager(this)
        val mainAdapter = MainAdapter(
            arrayListOf(
                "ShapeTextView",
                "SquareMoreView",
                "ScrollView",
                "ProgressView",
                "EditView",
                "TextView",
                "FragmentView",
                "DialogView",
                "TitleView"
            )
        )
        mainAdapter.setOnItemClickListener { adapter, view, position ->
            val item = mainAdapter.getItem(position)
            when (item) {
                "ShapeTextView" -> startActivity(Intent(this, SquareActivity::class.java))
                "SquareMoreView" -> startActivity(Intent(this, SquareMoreActivity::class.java))
                "ScrollView" -> startActivity(Intent(this, ScrollActivity::class.java))
                "ProgressView" -> startActivity(Intent(this, ProgressActivity::class.java))
                "EditView" -> startActivity(Intent(this, EditActivity::class.java))
                "TextView" -> startActivity(Intent(this, TextActivity::class.java))
                "FragmentView" -> startActivity(Intent(this, FragmentActivity::class.java))
                "DialogView" -> startActivity(Intent(this, DialogActivity::class.java))
                "TitleView" -> startActivity(Intent(this, TitleActivity::class.java))
            }

        }
        listView.adapter = mainAdapter

    }
}